#include <stdlib.h> 
#include <stdio.h> 
#include <cstdint> 
#include <type_traits> 
#include <cstddef> 

#define ngx_align_ptr(p, a) \
    (u_char *) (((uintptr_t) (p) + ((uintptr_t) a - 1)) & ~((uintptr_t) a - 1))

int main(int argc, char **argv) {
    printf("max align:%lu\n", alignof(std::max_align_t));
    printf("%lu\n", sizeof(std::aligned_storage<sizeof(double), alignof(double)>::type));
    
    int a = 0;
    printf("%p\n", (void *)&a);

    u_char* m = ngx_align_ptr(&a, alignof(std::max_align_t));
    printf("%p\n", (void *)m);

    for (int i = 0; i < 1000; ++i) {
        u_char* j = ngx_align_ptr(i, 16);
        printf("%lu\n", ((uintptr_t) j) % 16);
    }

    return 0;
}
